local skel = fk.CreateSkill {
  name = "emo__duoxue",
}

Fk:loadTranslationTable{
  ["emo__duoxue"] = "多学",
  [":emo__duoxue"] = "出牌阶段各限一次，你可以将：<font color='red'>♥</font>牌当【幸运硬币】；♠牌当【定时炸弹】；<font color='red'>♦</font>牌当【乐不思蜀】；♣牌当【兵粮寸断】使用",

  ["#emo__duoxue"] = "将<font color='red'>♥</font>牌当【硬币】；♠牌当【炸弹】；<font color='red'>♦</font>牌当【乐蜀】；♣牌当【兵粮】使用",
}

skel:addEffect("viewas", {
  prompt = "#emo__duoxue",
  pattern = "lucky_coin,timebomb,indulgence,supply_shortage",
  card_filter = function (self, player, to_select, selected)
    if #selected == 1 then return false end
    local suit = Fk:getCardById(to_select).suit
    if suit == Card.NoSuit or table.contains(player:getTableMark("emo__duoxue_used-phase"), suit) then return false end
    local c
    if suit == Card.Heart then
      c = Fk:cloneCard("lucky_coin")
    elseif suit == Card.Diamond then
      c = Fk:cloneCard("indulgence")
    elseif suit == Card.Club then
      c = Fk:cloneCard("supply_shortage")
    elseif suit == Card.Spade then
      c = Fk:cloneCard("timebomb")
    end
    if not c or not c.skill then return false end
    if Fk.currentResponsePattern then
      return Exppattern:Parse(Fk.currentResponsePattern):match(c)
    else
      return player:canUse(c)
    end
  end,
  view_as = function (self, player, cards)
    if #cards ~= 1 then return nil end
    local suit = Fk:getCardById(cards[1]).suit
    local c
    if suit == Card.Heart then
      c = Fk:cloneCard("lucky_coin")
    elseif suit == Card.Diamond then
      c = Fk:cloneCard("indulgence")
    elseif suit == Card.Club then
      c = Fk:cloneCard("supply_shortage")
    elseif suit == Card.Spade then
      c = Fk:cloneCard("timebomb")
    else
      return nil
    end
    c.skillName = self.name
    c:addSubcards(cards)
    return c
  end,
  before_use = function (self, player, use)
    player.room:addTableMark(player, "emo__duoxue_used-phase", use.card.suit)
  end,
  enabled_at_response = Util.FalseFunc,
  enabled_at_play = function (self, player)
    return #player:getTableMark("emo__duoxue_used-phase") < 4
  end,
})

return skel
